package com.easy.cms.material.service.impl;

import com.easy.cms.material.model.EnterpriseMaterialBinding;
import com.easy.cms.material.repository.EnterpriseMaterialBindingRepository;
import com.easy.cms.material.service.EnterpriseMaterialBindingService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class EnterpriseMaterialBindingServiceImpl implements EnterpriseMaterialBindingService {
    private final EnterpriseMaterialBindingRepository repository;

    public EnterpriseMaterialBindingServiceImpl(EnterpriseMaterialBindingRepository repository) {
        this.repository = repository;
    }

    @Override
    public EnterpriseMaterialBinding save(EnterpriseMaterialBinding binding) {
        return repository.save(binding);
    }

    @Override
    public void deleteById(Long id) {
        repository.deleteById(id);
    }

    @Override
    public EnterpriseMaterialBinding update(EnterpriseMaterialBinding binding) {
        return repository.save(binding);
    }

    @Override
    public EnterpriseMaterialBinding findById(Long id) {
        return repository.findById(id).orElse(null);
    }

    @Override
    public Page<EnterpriseMaterialBinding> findByMaterialNameAndCustomCode(String materialName, String customCode, Pageable pageable) {
        return repository.findByMaterialNameAndCustomCode(materialName, customCode, pageable);
    }
}